<layout name="Layout/layout" />
<div class="row">
	<div class="col-lg-12">
		<h1 class="page-header">权限</h1>
	</div>
	<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
<div class="row">
	<div class="col-lg-12">
		<div class="panel panel-default">
			<div class="panel-heading">
				分配权限
			</div>
			<!-- /.panel-heading -->
			<div class="panel-body">
				<?php 
					foreach($now as $k=>$v){
						?>
						<div class="panel panel-default">
							<div class="panel-heading">角色：{:getRoleById($k)}</div>
							<div class="panel-body">
								<form role="form" action="{:U('Admin/Access/allotHandle')}" method="post">
									<input type="hidden" name="rid" value="{$k}">
									<div class="form-group">
										<label>选择权限：</label><br />
										<foreach name="accesslist" item="v">
								
											<label class="checkbox-inline app-level">
												<input name="accesses[]" type="checkbox" value="{$v[0]['id']}" {:accessCheck($k ,$v[0]['id'])}> {$v[0]['name']}
											</label>
											<hr />
											<?php
											foreach($v[1] as $vo){
											?>
												<label class="checkbox-inline controller-level">
													<input name="accesses[]" type="checkbox" value="{$vo[0]['id']}" {:accessCheck($k ,$vo[0]['id'])}> {$vo[0]['name']}
												</label>
												<hr />
												<?php
												foreach($vo[1] as $voo){
												?>
													<label class="checkbox-inline action-level">
														<input name="accesses[]" type="checkbox" value="{$voo['id']}" {:accessCheck($k ,$voo['id'])}> {$voo['name']}
													</label>
													
													<?php
												}
												echo '<hr />';
											}
											?>
										</foreach>
									</div>
									<button type="submit" class="btn btn-default">保存</button>
								</form>
							</div>
						</div>
						<?php
					}
				?>
				<hr />
				<form role="form" action="{:U('Admin/Access/allotHandle')}" method="post">
					<div class="form-group">
						<label>选择一个角色</label>
						<select name="rid" class="form-control">
							<foreach name="rolelist" item="v">
								<option value="{$v['id']}">{$v['name']}</option>
							</foreach>
						</select>
						
					</div>
					<div class="form-group">
						<label>选择权限：</label><br />
						<foreach name="accesslist" item="v">
							
							<label class="checkbox-inline app-level">
								<input name="accesses[]" type="checkbox" value="{$v[0]['id']}"> {$v[0]['name']}
							</label>
							<hr />
							<?php
							foreach($v[1] as $vo){
							?>
								<label class="checkbox-inline controller-level">
									<input name="accesses[]" type="checkbox" value="{$vo[0]['id']}"> {$vo[0]['name']}
								</label>
								<hr />
								<?php
								foreach($vo[1] as $voo){
								?>
									<label class="checkbox-inline action-level">
										<input name="accesses[]" type="checkbox" value="{$voo['id']}"> {$voo['name']}
									</label>
									
									<?php
								}
								echo '<hr />';
							}
							?>
						</foreach>
					</div>
					<button type="submit" class="btn btn-default">新增</button>
				</form>
			</div>
			<!-- /.panel-body -->
		</div>
		<!-- /.panel -->
	</div>
	<!-- /.col-lg-12 -->
</div>